/**
 * 
 */
package com.tjtt.tdm.flow.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.tjtt.common.utils.ExcelExportUtil;
import com.tjtt.common.utils.StringUtil;
import com.tjtt.gwm.bean.Gongyingshang;
import com.tjtt.tdm.form.service.IAutoFormService;
import com.tjtt.tdm.base.BaseAction;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.exception.ServiceException;
import com.tjtt.tdm.flow.bean.FlowTask;
import com.tjtt.tdm.base.PubMethod;
import com.tjtt.tdm.flow.service.IWorkflowService;

/**
 * 
 * @author 张海娜
 *
 */
public class WorkflowAction extends BaseAction{

	private static final long serialVersionUID = -5436400888328765984L;
	private IWorkflowService workflowService;
    private String state;
    private String oldstate;
    private String path;
    private String flowid;
    private String hegestate;
    private String buhegestate;
    private IAutoFormService autoFormService;
	
	public String getHegestate() {
		return hegestate;
	}

	public void setHegestate(String hegestate) {
		this.hegestate = hegestate;
	}

	public String getBuhegestate() {
		return buhegestate;
	}

	public void setBuhegestate(String buhegestate) {
		this.buhegestate = buhegestate;
	}

	/**
	 * 发起流程
	 * @author zhn
	 * @date 2013-11-4 上午10:49:47
	 */
	public void queryFaQiWorkExec() {
		try {
			String flowtypes = getRequest().getParameter("FLOWNAME");
			String flownames = getRequest().getParameter("FLOW_NAME");
			String type = getRequest().getParameter("type");
			String flowid = getRequest().getParameter("flowid");
			String flowtype="";
			String flowname="";
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("type", type);
			filterMap.put("flowid", flowid);
			filterMap.put("userId", this.getUserId());

			if(!"".equals(flowtypes)&&flowtypes!=null){
				flowtype = java.net.URLDecoder.decode(flowtypes,"UTF-8");
			}
			if(!"".equals(flownames)&&flownames!=null){
							flowname = java.net.URLDecoder.decode(flownames,"UTF-8");
						}	
			filterMap.put("flowtype", flowtype);					
			filterMap.put("flowname", flowname);
			String[] viewArray = { "ID","FLOWNAME","FLOW_NAME", "FLOW_TYPE_ID", "FLOW_STATE_ID","FLOW_STATE_NAME","FLOW_ACTION_TYPE","NEXT_ROLES_ID",
								"NEXT_ROLES_NAME","NEXT_USERS_ID","NEXT_USERS_NAME","ADD_TIME","ADD_USER_ID","ADD_USER_NAME","flowtaskinfoid","MAIN_ID"};
			// 查询所有的数据
			PageResult result = workflowService.queryFaQiWorkExec(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 理化中心数据查询
	 * @author zhn
	 * @date Jun 11, 2014 10:35:52 AM
	 */
	public void queryRationalizeDataList() {
		try {
			
			String testNo = StringUtil.encodingUrl(getRequest().getParameter("testNo"));
			String WEITUODANWEI = StringUtil.encodingUrl(getRequest().getParameter("WEITUODANWEI"));
			String TEST_NO = StringUtil.encodingUrl(getRequest().getParameter("TEST_NO"));
			String WEITUORIQ = StringUtil.encodingUrl(getRequest().getParameter("WEITUORIQ"));
			String WEITUORIQTO = StringUtil.encodingUrl(getRequest().getParameter("WEITUORIQTO"));
			String T_JSTJ = StringUtil.encodingUrl(getRequest().getParameter("T_JSTJ"));
			String WEITUOBIANHAO = StringUtil.encodingUrl(getRequest().getParameter("WEITUOBIANHAO"));
			String TDM_GUIGE = StringUtil.encodingUrl(getRequest().getParameter("TDM_GUIGE"));
			String TDM_CAILIAOPAIHAO = StringUtil.encodingUrl(getRequest().getParameter("TDM_CAILIAOPAIHAO"));
			String LINGJIANMINGC = StringUtil.encodingUrl(getRequest().getParameter("LINGJIANMINGC"));
			String LINGJIANTUHAO = StringUtil.encodingUrl(getRequest().getParameter("LINGJIANTUHAO"));
			String LUHAO = StringUtil.encodingUrl(getRequest().getParameter("LUHAO"));
			String PIHAO = StringUtil.encodingUrl(getRequest().getParameter("PIHAO"));
			String PLACE = StringUtil.encodingUrl(getRequest().getParameter("PLACE"));
			String JISHUTIAOJIAN = StringUtil.encodingUrl(getRequest().getParameter("JISHUTIAOJIAN"));
			String T_XMZ = StringUtil.encodingUrl(getRequest().getParameter("T_XMZ"));
			String BAOGAOHAO = StringUtil.encodingUrl(getRequest().getParameter("BAOGAOHAO"));
			String T_PDYJ = StringUtil.encodingUrl(getRequest().getParameter("T_PDYJ"));
			String T_JCS =StringUtil.encodingUrl( getRequest().getParameter("T_JCS"));
			String step =StringUtil.encodingUrl( getRequest().getParameter("step"));
			String wczt = getRequest().getParameter("wczt");
			String init =StringUtil.encodingUrl( getRequest().getParameter("init"));
			
			Map<String, String> filterMap = getPagerMap();
			filterMap.put("WEITUODANWEI", WEITUODANWEI);
			filterMap.put("testNo", testNo);
			filterMap.put("TEST_NO", TEST_NO);
			filterMap.put("WEITUORIQ", WEITUORIQ);
			filterMap.put("step", step);
			filterMap.put("WEITUORIQTO", WEITUORIQTO);
			filterMap.put("T_JSTJ", T_JSTJ);
			filterMap.put("WEITUOBIANHAO", WEITUOBIANHAO);					
			filterMap.put("TDM_GUIGE", TDM_GUIGE);
			filterMap.put("TDM_CAILIAOPAIHAO", TDM_CAILIAOPAIHAO);
			filterMap.put("LINGJIANMINGC", LINGJIANMINGC);
			filterMap.put("LINGJIANTUHAO", LINGJIANTUHAO);
			filterMap.put("LUHAO", LUHAO);
			filterMap.put("PIHAO", PIHAO);					
			filterMap.put("PLACE", PLACE);
			filterMap.put("JISHUTIAOJIAN", JISHUTIAOJIAN);
			filterMap.put("T_XMZ", T_XMZ);
			filterMap.put("BAOGAOHAO", BAOGAOHAO);
			filterMap.put("T_PDYJ", T_PDYJ);
			filterMap.put("T_JCS", T_JCS);	
			filterMap.put("wczt", wczt);	
			filterMap.put("init", init);		
			String[] viewArray = { "ID", "clph","T_JSTJ","ypbh","jyxm","rclry","rclsj","jgwcqkry","jgwcqksj","jgshqrry","jgshqrsj","ITEMRESULT","T_PDYJ","ANALYSE_USER","proc2_state",
								"ANALYSE_TIME","check_user","sjjd_state","check_time","report_user","PROC7_state","report_time","reportcheck_user","shbg_state","reportcheck_time","approval_user","PZBG_state","approval_time","Reportsummary_user","PROC3_state","Reportsummary_time","ysjl_path","baogao_path","HUIZONGBG_PATH"};
			// 查询所有的数据
			PageResult result = workflowService.queryRationalizeDataList(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public void queryRationalizeDataZongList() {
		try {
			String WEITUODANWEI = StringUtil.encodingUrl(getRequest().getParameter("WEITUODANWEI"));
			String TEST_NO = StringUtil.encodingUrl(getRequest().getParameter("TEST_NO"));
			String WEITUORIQ = StringUtil.encodingUrl(getRequest().getParameter("WEITUORIQ"));
			String WEITUORIQTO = StringUtil.encodingUrl(getRequest().getParameter("WEITUORIQTO"));
			String T_JSTJ = StringUtil.encodingUrl(getRequest().getParameter("T_JSTJ"));
			String WEITUOBIANHAO = StringUtil.encodingUrl(getRequest().getParameter("WEITUOBIANHAO"));
			String TDM_GUIGE = StringUtil.encodingUrl(getRequest().getParameter("TDM_GUIGE"));
			String TDM_CAILIAOPAIHAO = StringUtil.encodingUrl(getRequest().getParameter("TDM_CAILIAOPAIHAO"));
			String LINGJIANMINGC = StringUtil.encodingUrl(getRequest().getParameter("LINGJIANMINGC"));
			String LINGJIANTUHAO = StringUtil.encodingUrl(getRequest().getParameter("LINGJIANTUHAO"));
			String LUHAO = StringUtil.encodingUrl(getRequest().getParameter("LUHAO"));
			String PIHAO = StringUtil.encodingUrl(getRequest().getParameter("PIHAO"));
			String PLACE = StringUtil.encodingUrl(getRequest().getParameter("PLACE"));
			String JISHUTIAOJIAN = StringUtil.encodingUrl(getRequest().getParameter("JISHUTIAOJIAN"));
			String T_XMZ = StringUtil.encodingUrl(getRequest().getParameter("T_XMZ"));
			String BAOGAOHAO = StringUtil.encodingUrl(getRequest().getParameter("BAOGAOHAO"));
			String T_PDYJ = StringUtil.encodingUrl(getRequest().getParameter("T_PDYJ"));
			String T_JCS =StringUtil.encodingUrl( getRequest().getParameter("T_JCS"));
			String step =StringUtil.encodingUrl( getRequest().getParameter("step"));
			String wczt = getRequest().getParameter("wczt");
			String init =StringUtil.encodingUrl( getRequest().getParameter("init"));
			
			Map<String, String> filterMap = getPagerMap();
			filterMap.put("WEITUODANWEI", WEITUODANWEI);
			filterMap.put("TEST_NO", TEST_NO);
			filterMap.put("WEITUORIQ", WEITUORIQ);
			filterMap.put("step", step);
			filterMap.put("WEITUORIQTO", WEITUORIQTO);
			filterMap.put("T_JSTJ", T_JSTJ);
			filterMap.put("WEITUOBIANHAO", WEITUOBIANHAO);					
			filterMap.put("TDM_GUIGE", TDM_GUIGE);
			filterMap.put("TDM_CAILIAOPAIHAO", TDM_CAILIAOPAIHAO);
			filterMap.put("LINGJIANMINGC", LINGJIANMINGC);
			filterMap.put("LINGJIANTUHAO", LINGJIANTUHAO);
			filterMap.put("LUHAO", LUHAO);
			filterMap.put("PIHAO", PIHAO);					
			filterMap.put("PLACE", PLACE);
			filterMap.put("JISHUTIAOJIAN", JISHUTIAOJIAN);
			filterMap.put("T_XMZ", T_XMZ);
			filterMap.put("BAOGAOHAO", BAOGAOHAO);
			filterMap.put("T_PDYJ", T_PDYJ);
			filterMap.put("T_JCS", T_JCS);	
			filterMap.put("wczt", wczt);	
			filterMap.put("init", init);		
			String[] viewArray = { "TEST_NO","WEITUODANWEI","WEITUORIQ","WEITUOBIANHAO"};
			// 查询所有的数据
			PageResult result = workflowService.queryRationalizeDataZongList(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 理化中心导出excel
	 * @author zhn
	 * @date Jun 11, 2014 4:49:40 PM
	 */
	public void exportExcelRationalData()
	{
		List<String> list = new ArrayList<String>();
		List<String> fieldlist = new ArrayList<String>();
		List<String> fieldlist1 =new ArrayList<String>();
		HttpServletRequest request = ServletActionContext.getRequest();
		
		String extitleName= "委托单位,委托日期,委托编号,试验编号,材料牌号,技术条件,样品编号,检验项目,热处理人员,热处理时间,加工人员,加工时间,加工审核人员,加工审核时间,项目结果,是否合格,分配人,分析日期,校核人,校核日期,报告人,报告日期,报告审核人,报告审核日期,报告批准人,报告批准日期,报告汇总人,报告汇总日期,原始记录路径,报告路径,汇总报告路径,";
		String fieldsNames= "WEITUODANWEI,WEITUORIQ,WEITUOBIANHAO,TEST_NO,clph,T_JSTJ,ypbh,jyxm,rclry,rclsj,jgwcqkry,jgwcqksj,jgshqrry,jgshqrsj,ITEMRESULT,T_PDYJ,ANALYSE_USER,ANALYSE_TIME,check_user,check_time,report_user,report_time,reportcheck_user,reportcheck_time,approval_user,approval_time,Reportsummary_user,Reportsummary_time,ysjl_path,baogao_path,HUIZONGBG_PATH,";
	
		String[] titleName=extitleName.split(",");
		for (int i=0;i<titleName.length;i++) {
			list.add(titleName[i]);
		}
		
		String[] fieldsName=fieldsNames.split(",");
		for (int j=0;j<fieldsName.length;j++) {
			fieldlist.add(fieldsName[j].toUpperCase());
		}
					
		String[] s={"ID","WEITUODANWEI","WEITUORIQ","WEITUOBIANHAO", "TEST_NO","clph","T_JSTJ", "SAMPLE_ID","T_JYXM","rclry","rclsj","jgwcqkry","jgwcqksj","jgshqrry","jgshqrsj","ITEMRESULT","T_PDYJ","ANALYSE_USER",
				"ANALYSE_TIME","check_user","check_time","report_user","report_time","reportcheck_user","reportcheck_time","approval_user","approval_time","Reportsummary_user","Reportsummary_time","ysjl_path","baogao_path","HUIZONGBG_PATH"};
		for(int i=0;i<s.length;i++){
			fieldlist1.add(s[i].toUpperCase());
		}
		String WEITUODANWEI = StringUtil.encodingUrl(getRequest().getParameter("WEITUODANWEI"));
		String TEST_NO = StringUtil.encodingUrl(getRequest().getParameter("TEST_NO"));
		String WEITUORIQ = StringUtil.encodingUrl(getRequest().getParameter("WEITUORIQ"));
		String T_JSTJ = StringUtil.encodingUrl(getRequest().getParameter("T_JSTJ"));
		String WEITUOBIANHAO = StringUtil.encodingUrl(getRequest().getParameter("WEITUOBIANHAO"));
		String TDM_GUIGE = StringUtil.encodingUrl(getRequest().getParameter("TDM_GUIGE"));
		String TDM_CAILIAOPAIHAO = StringUtil.encodingUrl(getRequest().getParameter("TDM_CAILIAOPAIHAO"));
		String LINGJIANMINGC = StringUtil.encodingUrl(getRequest().getParameter("LINGJIANMINGC"));
		String LINGJIANTUHAO = StringUtil.encodingUrl(getRequest().getParameter("LINGJIANTUHAO"));
		String LUHAO = StringUtil.encodingUrl(getRequest().getParameter("LUHAO"));
		String PIHAO = StringUtil.encodingUrl(getRequest().getParameter("PIHAO"));
		String PLACE = StringUtil.encodingUrl(getRequest().getParameter("PLACE"));
		String JISHUTIAOJIAN = StringUtil.encodingUrl(getRequest().getParameter("JISHUTIAOJIAN"));
		String T_XMZ = StringUtil.encodingUrl(getRequest().getParameter("T_XMZ"));
		String BAOGAOHAO = StringUtil.encodingUrl(getRequest().getParameter("BAOGAOHAO"));
		String T_PDYJ = StringUtil.encodingUrl(getRequest().getParameter("T_PDYJ"));
		String T_JCS =StringUtil.encodingUrl( getRequest().getParameter("T_JCS"));
		String wczt = getRequest().getParameter("wczt"); 
		
		Map filterMap = getPagerMap();
		filterMap.put("WEITUODANWEI", WEITUODANWEI);
		filterMap.put("TEST_NO", TEST_NO);
		filterMap.put("WEITUORIQ", WEITUORIQ);
		filterMap.put("T_JSTJ", T_JSTJ);
		filterMap.put("WEITUOBIANHAO", WEITUOBIANHAO);					
		filterMap.put("TDM_GUIGE", TDM_GUIGE);
		filterMap.put("TDM_CAILIAOPAIHAO", TDM_CAILIAOPAIHAO);
		filterMap.put("LINGJIANMINGC", LINGJIANMINGC);
		filterMap.put("LINGJIANTUHAO", LINGJIANTUHAO);
		filterMap.put("LUHAO", LUHAO);
		filterMap.put("PIHAO", PIHAO);					
		filterMap.put("PLACE", PLACE);
		filterMap.put("JISHUTIAOJIAN", JISHUTIAOJIAN);
		filterMap.put("T_XMZ", T_XMZ);
		filterMap.put("BAOGAOHAO", BAOGAOHAO);
		filterMap.put("T_PDYJ", T_PDYJ);
		filterMap.put("T_JCS", T_JCS);			
		filterMap.put("wczt", wczt);			
		 
		ExcelExportUtil excelutil = new ExcelExportUtil();
		String fileName1 ="理化中心数据导出列表.xlsx";
		String fileName ="lhzxsjdc.xlsx";
		filterMap.put("rows",9999);
		//List setListForExcel=workflowService.findRationData(filterMap);
		//excelutil.exportExcel(fileName,list,fieldlist,fieldlist1,filterMap,setListForExcel);
		String userNm = ServletActionContext.getRequest().getSession().getAttribute("username").toString();
//			File file = new File("d:"+File.separator);
		try {
			filterMap.put("rows",999);
			List setListForExcel=workflowService.findRationData(filterMap);
			//excelutil.exportlhExcel(fileName,list,fieldlist,fieldlist1,filterMap,setListForExcel,userNm,new Timestamp(System.currentTimeMillis()));
			System.out.println("====="+fieldlist);
			ExcelExportUtil exExcelUtil = new ExcelExportUtil();
			List<Map<String, Object>> dataList = getDataList(fieldlist1,filterMap,setListForExcel);
			List<String> headList = list;
			List<String> fieldList = fieldlist;	
			XSSFWorkbook wb = new XSSFWorkbook();
			String filePath =  getRequest().getSession().getAttribute("SYS_FILEPATH").toString()+"/export/"+PubMethod.GetTimerName()+"/";
			File targetFile = new File(filePath);
			if ( ! (targetFile.exists())  &&   ! (targetFile.isDirectory()))  {
		        boolean  creadok  =  targetFile.mkdirs();
		        if (creadok)  {
		           System.out.println( " ok:创建文件夹成功！ " );
		       } else  {
		           System.out.println( " err:创建文件夹失败！ " ); 
		
		           
		       } 
		   } 
			filePath = filePath + fileName;
			File targetFile1 = new File(filePath);
			if (targetFile1.exists()) {
				targetFile1.delete();
			} else {
				targetFile1.createNewFile();
			}
			FileOutputStream fileOut = new FileOutputStream(filePath);
			// 创建新的Excel 工作簿
			// 在Excel工作簿中建一工作表，其名为缺省值
			// 如要新建一名为"效益指标"的工作表，其语句为：
			// HSSFSheet sheet = workbook.createSheet("效益指标");
			XSSFSheet sheet = wb.createSheet();
			// 在索引0的位置创建行（最顶端的行）
			XSSFRow row = sheet.createRow(0);
			for (int i = 0; i < headList.size(); i++) {
				XSSFCell cell = row.createCell(i);
				cell.setCellType(XSSFCell.CELL_TYPE_STRING);
				cell.setCellValue(headList.get(i));
			}
			String str1;
			for (int n = 0; n < dataList.size(); n++) {
				XSSFRow row_value = sheet.createRow(n + 1);
				Map<String, Object> dataMap = dataList.get(n);
				for (int i = 0; i < fieldList.size(); i++) {
					XSSFCell cell = row_value.createCell(i);
					cell.setCellType(XSSFCell.CELL_TYPE_STRING);
					str1=objToString(dataMap.get(fieldList.get(i)));
					if(DataTypeJudge(fieldList.get(i))){
						cell.setCellValue(DataTypeToCN(fieldList.get(i),dataMap.get(fieldList.get(i))));
					}else{
						cell.setCellValue(objToString(dataMap.get(fieldList.get(i))));
					}
				}
			}
			wb.write(fileOut);
			fileOut.close();
			if(targetFile1.exists())
			{
				getResponse().setHeader("Server","www.tjtt.com");
				getResponse().setHeader("Content-Type", "application/octet-stream");
				getResponse().setHeader("Content-Length", String.valueOf(targetFile1.length()));
				getResponse().setHeader("Content-Disposition", "attachment; filename=\"" + java.net.URLEncoder.encode(fileName1,"UTF-8").replace( "+",   "%20")  + "\"");	
				try {
					OutputStream downloadStream=getResponse().getOutputStream();
					FileInputStream fin = new FileInputStream(targetFile1);
					byte[] b=new byte[1024];	
					int length=fin.read(b);
					while(length>0)
					{
						downloadStream.write(b,0,length);
						length=fin.read(b);
					}
					downloadStream.flush();
				} catch (IOException e) {
					e.printStackTrace();
				}			
			}	
			
				// fileOut.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
		private List<Map<String, Object>> getDataList(List<String> fieldlist,Map filterMap,List setListForExcel) {
			/**
			 * 数据集合
			 */
			List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
			List<?> list = new ArrayList(); 
			list =setListForExcel;
			String[] st = new String[fieldlist.size()];
			Object[] obj = new Object[list.size()];
			for(int j=0;j<list.size();j++){
				Map<String, Object> map = new HashMap<String, Object>();
				obj = (Object[])list.get(j);
//				System.out.print(obj);
				for(int i=0;i<fieldlist.size();i++){
					map.put((String)fieldlist.get(i),obj[i]);
				}
				dataList.add(j,map);
				
			}
			return dataList;
		}
		/***
		 * 判断业务状态进行输出控制
		 * @return
		 */
		private static String DataTypeToCN(Object obj1,Object obj2) {
			/*if(obj1.toString().equals("STATE")){
				if(obj2.toString().equals("0")){
					return "aaaaaa";
				}else if(obj2.toString().equals("1")){
					return "bbbb";
				}else{
					return "acbdfweerfqwe";	
				}
			}else if(obj1.toString().equals("OVERDATE")){
				return obj2.toString().split("-")[1]+"月";
				
			}else{*/
				return obj1.toString();
//			}
			
		}
		/***
		 * 判断此字段数据是否值得进行逻辑值的转换
		 * @param obj
		 * @return
		 */
		private static Boolean DataTypeJudge(Object obj) {
			/*if(obj.toString().equals("STATE")){
				return true;
			}else if(obj.toString().equals("OVERDATE")){
				return true;
			}else{
				
			}*/return false;
		}
		private static String objToString(Object obj) {
			if (obj == null) {
				return "";
			} else {
				if (obj instanceof String) {
					return (String) obj;
				} else if (obj instanceof Date) {
					//return dateToString();
					SimpleDateFormat stf=new SimpleDateFormat("yyyy-MM-dd");
					String str=stf.format(obj);
					return str;
					//return null;// DateUtil.dateToString((Date)
					// obj,DateUtil.DATESTYLE_SHORT_EX);
				} else {
					return obj.toString();
				}
			}
		}

	/**
	 * 我的试验中心代办试验显示到jqrid
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 张海娜
	 * @date 2013-2-22 下午03:53:34
	 */
	public void queryWaitWorkExec() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryWaitWorkListNew(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryDaiqian() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryDaiqian(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryYiban() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","next_users_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryYiban(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryBanjie() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryBanjie(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryQingqiu() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryQingqiu(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryCaosong() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryCaosong(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryWancheng() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time","operatortime","haoshi"};
			// 查询所有的数据
			PageResult result = workflowService.queryWancheng(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void queryJinxing() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time","haoshi"};
			// 查询所有的数据
			PageResult result = workflowService.queryJinxing(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 我的请求
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author wxj
	 * @date 2013-2-22 下午03:53:34
	 */
	public void queryMyRequestExec() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String jdmc = getRequest().getParameter("jdmc");
			String rwmc = getRequest().getParameter("rwmc");
			String type = getRequest().getParameter("type");
			String flowid = getRequest().getParameter("flowid");
			String flag = getRequest().getParameter("flag");
			String id = getRequest().getParameter("id");
			
			String renwuname = getRequest().getParameter("renwuname");
			String shibiehao = getRequest().getParameter("shibiehao");
			String weituoren = getRequest().getParameter("weituoren");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");
			String renwustate = getRequest().getParameter("renwustate");
			
			String flowtype="";
			String flowname="";
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("type", type);
			filterMap.put("flowid", flowid);
			filterMap.put("flag", flag);
			filterMap.put("id", id);
			
			if(!"".equals(jdmc)&&jdmc!=null){
				jdmc = java.net.URLDecoder.decode(jdmc,"UTF-8");
			}
			if(!"".equals(rwmc)&&rwmc!=null){
				rwmc = java.net.URLDecoder.decode(rwmc,"UTF-8");
			}	
			filterMap.put("jdmc", jdmc);					
			filterMap.put("rwmc", rwmc);
			if(!"".equals(renwuname)&&renwuname!=null){
				renwuname = java.net.URLDecoder.decode(renwuname,"UTF-8");
				filterMap.put("renwuname", renwuname);	
			}
			if(!"".equals(shibiehao)&&shibiehao!=null){
				shibiehao = java.net.URLDecoder.decode(shibiehao,"UTF-8");
				filterMap.put("shibiehao", shibiehao);	
			}
			if(!"".equals(weituoren)&&weituoren!=null){
				weituoren = java.net.URLDecoder.decode(weituoren,"UTF-8");
				filterMap.put("weituoren", weituoren);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			if(!"".equals(renwustate)&&renwustate!=null){
				filterMap.put("renwustate", renwustate);
			}
			String[] viewArray = {"ID","TASKID","FLOW_NAME","FLOWTYPEID","TASKINFOID","RENWUNAME", "WEITUODANSHIBIENO","LIANXIREN","SHENQINGDATE","SHUANGFANGYUEDINGDATE","FLOW_STATE_ID"};
			// 查询所有的数据
			PageResult result = workflowService.queryMyRequestExec(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			getRequest().setAttribute("flag", flag);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 查询报告
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 张海娜
	 * @date 2013-2-22 下午03:53:34
	 */
	public void queryReportlist() {
		try {
			Map<String, String> filterMap = getPagerMap();
			String[] viewArray = { "ID","FLOWNAME","FLOW_NAME", "FLOW_TYPE_ID", "FLOW_STATE_ID","FLOW_STATE_NAME","FLOW_ACTION_TYPE","INSTANCE_ID","NEXT_ROLES_ID",
								"NEXT_ROLES_NAME","NEXT_USERS_ID","NEXT_USERS_NAME","ADD_TIME","ADD_USER_ID","ADD_USER_NAME","URGENT:[{'1':'正常','2':'加急'}]"};
			// 查询所有的数据
			PageResult result = workflowService.queryReportlist(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 我的试验中心代办试验显示到jqrid
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 张海娜 quoted by zf 
	 * @date 2013-2-22 下午03:53:34
	 */
	public void queryWaitWorkExecMyTask() {
		try {
			String flowtypes = getRequest().getParameter("FLOWNAME");
			String flownames = getRequest().getParameter("FLOW_NAME");
			String renwuname = getRequest().getParameter("renwuname");
			String shibiehao = getRequest().getParameter("shibiehao");
			String weituoren = getRequest().getParameter("weituoren");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");
			String flowtype="";
			String flowname="";
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("state", "0");
			if(!"".equals(flowtypes)&&flowtypes!=null){
				flowtype = java.net.URLDecoder.decode(flowtypes,"UTF-8");
			}
			if(!"".equals(flownames)&&flownames!=null){
							flowname = java.net.URLDecoder.decode(flownames,"UTF-8");
						}	
			filterMap.put("flowtype", flowtype);					
			filterMap.put("flowname", flowname);
			if(!"".equals(renwuname)&&renwuname!=null){
				renwuname = java.net.URLDecoder.decode(renwuname,"UTF-8");
				filterMap.put("renwuname", renwuname);	
			}
			if(!"".equals(shibiehao)&&shibiehao!=null){
				shibiehao = java.net.URLDecoder.decode(shibiehao,"UTF-8");
				filterMap.put("shibiehao", shibiehao);	
			}
			if(!"".equals(weituoren)&&weituoren!=null){
				weituoren = java.net.URLDecoder.decode(weituoren,"UTF-8");
				filterMap.put("weituoren", weituoren);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "id","flowtaskinfoid","FLOW_NAME","flowname","flow_state_name","flow_type_id","weituodanbh","lianxiren","shenqingdate","renwuname"};
			// 查询所有的数据
			PageResult result = workflowService.queryWaitWorkListNewMyTask(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 我的协作
	 */
	public void queryXieZuoWaitWorkExec() {
		try {
			String flowtypes = getRequest().getParameter("FLOWNAME");
			String flownames = getRequest().getParameter("FLOW_NAME");
			String flowtype="";
			String flowname="";
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("state", "0");
			if(!"".equals(flowtypes)&&flowtypes!=null){
				flowtype = java.net.URLDecoder.decode(flowtypes,"UTF-8");
			}
			if(!"".equals(flownames)&&flownames!=null){
							flowname = java.net.URLDecoder.decode(flownames,"UTF-8");
						}	
			filterMap.put("flowtype", flowtype);					
			filterMap.put("flowname", flowname);
			String[] viewArray = { "ID","FLOWNAME","FLOW_NAME", "FLOW_TYPE_ID", "FLOW_STATE_ID","FLOW_STATE_NAME","FLOW_ACTION_TYPE","INSTANCE_ID","NEXT_ROLES_ID",
								"NEXT_ROLES_NAME","NEXT_USERS_ID","NEXT_USERS_NAME","ADD_TIME","ADD_USER_ID","ADD_USER_NAME","TEST_NO"};
			// 查询所有的数据
			PageResult result = workflowService.queryXieZuoWaitWorkListNew(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 我的待签
	 */
	public void queryDaiQianWaitWorkExec() {
		try {
			String flowtypes = getRequest().getParameter("FLOWNAME");
			String flownames = getRequest().getParameter("FLOW_NAME");
			String flowtype="";
			String flowname="";
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("state", "0");
			if(!"".equals(flowtypes)&&flowtypes!=null){
				flowtype = java.net.URLDecoder.decode(flowtypes,"UTF-8");
			}
			if(!"".equals(flownames)&&flownames!=null){
							flowname = java.net.URLDecoder.decode(flownames,"UTF-8");
						}	
			filterMap.put("flowtype", flowtype);					
			filterMap.put("flowname", flowname);
			String[] viewArray = { "ID","FLOWNAME","FLOW_NAME", "FLOW_TYPE_ID", "FLOW_STATE_ID","FLOW_STATE_NAME","FLOW_ACTION_TYPE","NEXT_ROLES_ID",
					"NEXT_ROLES_NAME","NEXT_USERS_ID","NEXT_USERS_NAME","ADD_TIME","ADD_USER_ID","ADD_USER_NAME","flowtaskinfoid"};
            // 查询所有的数据
			PageResult result = workflowService.queryDaiQianWaitWorkListNew(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 确认签收
	 */
	public void updateQianShou(){
		try {
			String ids = getRequest().getParameter("ids");
			String userId = this.getUserId();
			String userName = this.getUserName();
			workflowService.updateQianShou(ids, userId, userName);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String output = "{\"ajaxResult\":\"success\"}";
			out.print(output);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 更改流程状态为加急
	 * @author zhn
	 * @date Apr 25, 2014 9:45:00 AM
	 */
	public void changeFlowTaskUngentExec() {
		PrintWriter out = PubMethod.GetPrintWriter(); 
		try {
			String id = getRequest().getParameter("id");
			String[] ids = id.split(",");
			for(int i=0;i<ids.length;i++){
				 
				String sql1 ="  select t.id,t.main_flow_id from FLOW_TASK t where t.shiyanbh  = '"+ids[i]+"' ";
				List list = autoFormService.getDatabySql(sql1);
				for(int j=0;j<list.size();j++){
					Object[] values = (Object[])list.get(j);
					//String mainFlowId = getRequest().getParameter("mainFlowId");
					if( null != values[1] && !"".equals(values[1].toString()) ){
						String sql3= " update Flow_Task set urgent ='加急',whetherjj = '加急' where MAIN_FLOW_ID = "+values[1].toString()+"";
						autoFormService.executeSql(sql3);
						String sql= " update Cf_Tdm t1 set t1.whetherjj ='加急' where t1.id in (select t.main_Id from Flow_Task t where t.MAIN_FLOW_ID = "+values[1].toString()+" )";
						autoFormService.executeSql(sql);
					}
					String sql2= " update Flow_Task set urgent ='加急',whetherjj = '加急' where id = "+values[0].toString()+"";
					autoFormService.executeSql(sql2);
					String sql= " update Cf_Tdm t1 set t1.whetherjj ='加急' where t1.id =(select t.main_Id from Flow_Task t where t.id = "+values[0].toString()+" )";
					autoFormService.executeSql(sql);
				}
				
			}
			//workflowService.changeFlowTaskUngentExec(id);
			String output = "{\"ajaxResult\":\"success\"}";
			out.print(output);
		} catch (Exception e) {
			String output = "{\"ajaxResult\":\"failure\"}";
			out.print(output);
			e.printStackTrace();
		}
	}
	/**
	 * 更改流程状态
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 周峰
	 * @date 2013-6-6
	 */
	public void changeFlowTaskState() {
		PrintWriter out = PubMethod.GetPrintWriter(); 
		try {
			String state = getRequest().getParameter("state");
			String ids = getRequest().getParameter("ids");
			workflowService.updateFlowTask(ids, state);
			String output = "{\"ajaxResult\":\"success\"}";
			out.print(output);
		} catch (Exception e) {
			String output = "{\"ajaxResult\":\"failure\"}";
			out.print(output);
			e.printStackTrace();
		}
	}
	
	/**
	 * 查询当前用户待办任务数目
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 周峰
	 * @date 2013-4-25
	 */
	public void getUndoWorkCount() {
		try {
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("state", "0");
			int count = workflowService.getUndoWorkCount(filterMap);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String output = "{\"ajaxResult\":\"success\",\"count\":\""+count+"\"}";
			out.print(output);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 试验进度管理
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 */
	public void queryWaitExperientWorkExec() {
		try {
			String type = getRequest().getParameter("type");
			String flowtypes = getRequest().getParameter("FLOWNAME");
			String renwuname = getRequest().getParameter("renwuname");
			String shibiehao = getRequest().getParameter("shibiehao");
			String weituoren = getRequest().getParameter("weituoren");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");
			String flowtype = new String();
			if(!"".equals(flowtypes)&&flowtypes!=null){
				flowtype = java.net.URLDecoder.decode(flowtypes,"UTF-8");
			}
			String flownames = getRequest().getParameter("FLOW_NAME");
			String flowname = new String();
			if(!"".equals(flownames)&&flownames!=null){
				flowname = java.net.URLDecoder.decode(flownames,"UTF-8");
			}
			
			Map<String, String> filterMap = getPagerMap();
			
			if(!"".equals(type)&&type!=null){
				filterMap.put("type", type);
			}
			filterMap.put("flowtype", flowtype);
			filterMap.put("flowname", flowname);
			if(!"".equals(renwuname)&&renwuname!=null){
				renwuname = java.net.URLDecoder.decode(renwuname,"UTF-8");
				filterMap.put("renwuname", renwuname);	
			}
			if(!"".equals(shibiehao)&&shibiehao!=null){
				shibiehao = java.net.URLDecoder.decode(shibiehao,"UTF-8");
				filterMap.put("shibiehao", shibiehao);	
			}
			if(!"".equals(weituoren)&&weituoren!=null){
				weituoren = java.net.URLDecoder.decode(weituoren,"UTF-8");
				filterMap.put("weituoren", weituoren);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "ID","FLOWTASKINFOID","FLOWNAME", "FLOW_NAME","FLOW_STATE_ID", "FLOW_STATE_NAME","FLOW_TYPE_ID","T_WEITUODANBH","WEITUOREN","WEITUOTIME","RENWUNAME","ADD_USER_NAME","ADD_TIME"};
			// 查询所有的数据
			PageResult result = workflowService.queryWaitExpWorkListNew(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 
	 * 
	 *@param
	 *@return
	 *@author zxm
	 *@date 2013-4-15 下午07:31:52
	 */
	public void queryWaitWorkJlExc(){
		try {
			Map<String, String> filterMap = getPagerMap();
			String[] viewArray = { "ID","FLOWNAME", "USERID", "CREATE_TIME","FLOWTYPE","STATE","STATEID","FLOWSTATE:[{'0':'待发起','1':'正在进行','2':'已完成','3':'挂起','4':'终止'}]"};
			// 查询所有的数据
			PageResult result = workflowService.queryWaitWorkListJL(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 我的理化中心代办试验显示到jqrid
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 张海娜
	 * @date 2013-2-22 下午03:53:34
	 */
	public void queryRationalizeWaitWorkExec() {
		try {
			Map<String, String> filterMap = getPagerMap();
			String[] viewArray = { "ID","FLOWNAME", "USERID", "REQUEST_DATE","FLOWTYPE_ID","STATE","STATEID","FLOWTYPE:[{'0':'待发起','1':'正在进行','2':'已完成','3':'挂起','4':'终止'}]"};
			// 查询所有的数据
			PageResult result = workflowService.queryRationalizeWaitWorkList(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 我的已办试验显示到jqrid
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 张海娜
	 * @date 2013-2-22 下午03:53:34
	 * @date 2013-5-14 周峰 修改
	 */
	public void queryDoneWorkExec() {
		try {
			String flowtypes = getRequest().getParameter("FLOWNAME");
			String flownames = getRequest().getParameter("FLOW_NAME");
			String renwuname = getRequest().getParameter("renwuname");
			String shibiehao = getRequest().getParameter("shibiehao");
			String weituoren = getRequest().getParameter("weituoren");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");
			String flowtype="";
			String flowname="";
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			filterMap.put("userId", userId);

			if(!"".equals(flowtypes)&&flowtypes!=null){
							flowtype = java.net.URLDecoder.decode(flowtypes,"UTF-8");
						}
			if(!"".equals(flownames)&&flownames!=null){
							flowname = java.net.URLDecoder.decode(flownames,"UTF-8");
						}	
			if(!"".equals(renwuname)&&renwuname!=null){
				renwuname = java.net.URLDecoder.decode(renwuname,"UTF-8");
				filterMap.put("renwuname", renwuname);	
			}
			if(!"".equals(shibiehao)&&shibiehao!=null){
				shibiehao = java.net.URLDecoder.decode(shibiehao,"UTF-8");
				filterMap.put("shibiehao", shibiehao);	
			}
			if(!"".equals(weituoren)&&weituoren!=null){
				weituoren = java.net.URLDecoder.decode(weituoren,"UTF-8");
				filterMap.put("weituoren", weituoren);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			filterMap.put("flowtype", flowtype);					
			filterMap.put("flowname", flowname);

			String[] viewArray = { "flowtaskinfoid","FLOWNAME","FLOW_NAME","flow_state_name","FLOW_STATE_ID","flowstatename","flowtaskid","weituodanbh","lianxiren","shenqingdate","renwuname"};
			// 查询所有的数据
			PageResult result = workflowService.queryDoneWorkList(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 流程操作详细显示到jqrid
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 张海娜
	 * @date 2013-3-12 下午02:23:26
	 */
	public void workDetailExec() {
		try {
			String id = getRequest().getParameter("id");
			String stateid = getRequest().getParameter("stateid");
			Map<String, String> filterMap = getPagerMap();
			String[] viewArray = { "ID","OPERATORPERSON", "OPERATORTIME", "STATUSBEFORE", "STATUSAFTER", "REMARK"};
			// 查询所有的数据
			if(stateid.equals("")){
				PageResult result = workflowService.queryWorkDetailList(id,filterMap);
				String returnStr = getColumnJson(result, viewArray);
				PrintWriter out = PubMethod.GetPrintWriter(); 
				out.print(returnStr);
			}else{
				PageResult result = workflowService.queryWorkDetailList2(stateid,id,filterMap);
				String returnStr = getColumnJson(result, viewArray);
				PrintWriter out = PubMethod.GetPrintWriter(); 
				out.print(returnStr);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public String getDetailedExec()
	{
		String ids = getRequest().getParameter("id");
		String sql = "select t.back_option from FLOW_task t  where t.id='"+ids+"' ";
		List sqlList = autoFormService.getDatabySql(sql);
		getRequest().setAttribute("backoption", sqlList.get(0));
		getRequest().setAttribute("flag", "view");
		return "viewDetail";
	}
	/**
	 * 查看规程审核流程图
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 
	 * @date 
	 */
	public String viewFlowinfo()
	{
		try {
			HttpServletRequest request = this.getRequest();
			WebApplicationContext factory = WebApplicationContextUtils.getRequiredWebApplicationContext(ServletActionContext.getServletContext());  
			String id = request.getParameter("id");
			String sql = " select t1.id,t1.flow_type_id from FLOW_TASK t1 left join Flow_Task_Info t2 on t1.id=t2.flow_task_id where t2.id='"+id+"'  ";
			List sqlList = autoFormService.getDatabySql(sql);

			Object[] value = (Object[])sqlList.get(0);
		    path = workflowService.getFlowfilepath(value[1].toString());
			FlowTask flowTask = workflowService.getFlowTaskById(value[0].toString());
			
			oldstate = flowTask.getFlowStateName();
			List lists =null;
			lists = workflowService.getFlowDetailList(Long.parseLong(value[0].toString()));
		    state ="{'finish': [";
		    for(int i = 0;i<lists.size();i++)
		    {
		    	Object[] values = (Object[])lists.get(i);
		    	if (i!=0)
		    	{
		    		state+=",";
		    	}
		    	state+="{'name':'"+values[7]+"','person':'"+values[1]+"','time':'"+values[2]+"'}";
		    }
		    state +="]}";
		    oldstate = ",";
			sql = " select t1.flow_state_id from Flow_Task_Info t1  where t1.flow_task_id='"+flowTask.getId()+"' and t1.state<>1 ";
			List oldList = autoFormService.getDatabySql(sql);
			for(int i = 0;i<oldList.size();i++)
		    {
				String stateid = oldList.get(i).toString();
				oldstate += stateid+",";
		    }
            getRequest().setAttribute("flowTaskId", value[0].toString());
			return "viewflow";
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
		
	}
	
	/**
	 * 
	 *方法描述：挂起已选的流程
	 *@author: 张海娜
	 *@date： 2013-4-1 下午2:31:37
	 *@return
	 *@throws IOException
	 *@throws ServiceException
	 */
	public String upRationalizesExec() throws IOException,ServiceException{
		setContentType();
		PrintWriter out = getResponse().getWriter();
	  	try {
	  		String ids = getRequest().getParameter("ids");
	  		if(ids !=null&&! ids.isEmpty()){
			String idss[] = ids.split(",");
				for(String id : idss){
					 
				}
	  		}
			out.print("{\"ajaxResult\":\"success\"}");
			//logService.saveLogInfo(this.getLogBase(), "", "","");
			return null;
	  	} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
			//logService.saveLogInfo(this.getLogBase(), "", "","");
			return null;
		}
	}
	/**
	 * 
	 *方法描述：恢复已选的流程
	 *@author: 张海娜
	 *@date： 2013-4-1 下午2:31:37
	 *@return
	 *@throws IOException
	 *@throws ServiceException
	 */
	public String restoreRationalizesExec() throws IOException,ServiceException{
		setContentType();
		PrintWriter out = getResponse().getWriter();
		try {
			String ids = getRequest().getParameter("ids");
			if(ids !=null&&! ids.isEmpty()){
				String idss[] = ids.split(",");
				for(String id : idss){
					 
				}
			}
			out.print("{\"ajaxResult\":\"success\"}");
			//logService.saveLogInfo(this.getLogBase(), "", "","");
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
			//logService.saveLogInfo(this.getLogBase(), "", "","");
			return null;
		}
	}
	
	/**
	 * 查询待办操作详情列表
	 */
	public void queryWaitWorkDetailExec() {
		try {
			String flowTaskId = getRequest().getParameter("flowTaskId");
			String testFlowId = getRequest().getParameter("testFlowId");
			String flowtypeId = getRequest().getParameter("flowtypeId");
		    String flowTypeId =  PubMethod.GetFlowid("flow.testCenterFlow");
			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			PageResult result = null;
			String[] viewArray = { "id","renwubh","statusbefore","statusafter", "operatorperson", "operatortime","statusbeforeid","statusafterid","flow_task_id","flow_type_id",
					"flow_action_type","actiontype","actiondescript","remark","main_id"};
			
			FlowTask flowTask = workflowService.getFlowTaskById(flowTaskId);
			
			filterMap.put("flowTaskId", flowTaskId);
			// 查询所有的数据
			result = workflowService.queryWaitWorkDetailList(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			PrintWriter out = PubMethod.GetPrintWriter(); 
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void getFlowback(){
		JSONObject json = new JSONObject();
		PrintWriter out = PubMethod.GetPrintWriter(); 
		try {
			String flowtaskinfoid = getRequest().getParameter("flowtaskinfoid");
			String strSql = "select ISLAHUI,LAHUISTATEID,LAHUISTATENAME,CHULIRENID,CHULIRENNAME from flow_task_info where id='"+flowtaskinfoid+"'";
			List lists = autoFormService.findAllBySql(strSql);
			Object[] objs = (Object[])lists.get(0);
			if (objs[0]!=null&&objs[0].toString().equals("1")){
				strSql = "update flow_task_info set FLOW_STATE_ID='"+objs[1]+"',FLOW_STATE_NAME='"+objs[2]+"'," +
						"NEXT_USERS_ID='"+objs[3]+"',NEXT_USERS_NAME='"+objs[4]+"',ISLAHUI='0' where id='"+flowtaskinfoid+"'";
				autoFormService.executeSql(strSql);
				json.put("result", "1");
			}
			else{
				json.put("result", "0");
			}
			out.print(json.toString());
		} catch (Exception e) {
			json.put("result", "error");
			out.print(json.toString());
			e.printStackTrace();
		}
	}
	
	
	public IWorkflowService getWorkflowService() {
		return workflowService;
	}

	public void setWorkflowService(IWorkflowService workflowService) {
		this.workflowService = workflowService;
	}

	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getOldstate() {
		return oldstate;
	}
	public void setOldstate(String oldstate) {
		this.oldstate = oldstate;
	}
	public String getFlowid() {
		return flowid;
	}
	public void setFlowid(String flowid) {
		this.flowid = flowid;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
	}

	public IAutoFormService getAutoFormService() {
		return autoFormService;
	}

	public void setAutoFormService(IAutoFormService autoFormService) {
		this.autoFormService = autoFormService;
	}
	
	/**
	 * 查看规程审核流程图(做特殊处理的方法for Fone)
	 * @return
	 * @throws IOException
	 * @throws ServiceException String
	 * @author 
	 * @date 
	 */
	public String viewCodeReviewFlowExecEspecial()
	{
		try {//+'&flowtypeid='+row.FLOW_TYPE_ID+'&stateid='+row.FLOW_STATE_ID
			HttpServletRequest request = this.getRequest();
			WebApplicationContext factory = WebApplicationContextUtils.getRequiredWebApplicationContext(ServletActionContext.getServletContext());  
			String opparamid = request.getParameter("opparamid");
			String sql = " select t.id,t.flow_type_id from FLOW_TASK t where t.MAIN_ID='"+opparamid+"'  ";
			List sqlList = autoFormService.getDatabySql(sql);
			Object[] value = (Object[])sqlList.get(0);
		    path = workflowService.getFlowfilepath(value[1].toString());
			FlowTask flowTask = workflowService.getFlowTaskById(value[0].toString());
			
			oldstate = flowTask.getFlowStateName();
			List lists =null;
			lists = workflowService.getFlowDetailList(Long.parseLong(value[0].toString()));
		    state ="{'finish': [";
		    for(int i = 0;i<lists.size();i++)
		    {
		    	Object[] values = (Object[])lists.get(i);
		    	if (i!=0)
		    	{
		    		state+=",";
		    	}
		    	state+="{'name':'"+values[7]+"','person':'"+values[1]+"','time':'"+values[2]+"'}";
		    }
		    state +="]}";
		    oldstate = "'"+flowTask.getFlowStateId()+"'";  
            getRequest().setAttribute("flowTaskId", value[0].toString());
			return "viewflow";
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
		
	}
	/*
	 * 查询流程状态及数量   一般、加急、延期
	 * wxj
	 */
	public void queryFlowtaskType() throws IOException{
		PrintWriter out = getResponse().getWriter();
		try {
			String 	flag = 	this.getRequest().getParameter("type");	
			String userId = this.getUserId();
			String roleId = this.getRole();
			
			Map<String, String> filterMap = getPagerMap();
			filterMap.put("flag", flag);
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			int taskCount = 0;
			if("0".equals(flag)){//一般
				PageResult result = workflowService.queryWaitWorkListNew(filterMap);
				taskCount = result.getData().size();
			}
			if("1".equals(flag)){//加急
				PageResult result = workflowService.queryDaiqian(filterMap);
				taskCount = result.getData().size();
			}
			if("2".equals(flag)){//延期
				String strSql = "select count(*) from flow_task_info t where t.next_users_id like '%,"+userId+",%' and t.back_state='1' ";
				List lists = autoFormService.findAllBySql(strSql);
				taskCount = Integer.parseInt(lists.get(0).toString());
			}
			out.print("{\"ajaxResult\":\"success\",\"taskCount\":\""+taskCount+"\"}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"ajaxResult\":\"error\"}");
		}
	}
	/*
	 * 删除任务
	 * wxj
	 */
	public void deleteFlowTask() throws IOException{
		String idAll = getRequest().getParameter("taskIds");//flawTaskId 
		String ids[] = idAll.split(",");
		PrintWriter out = getResponse().getWriter();
		try {
			String deleteFlowTask = "delete from FLOW_TASK t where t.id in ("+idAll+")";
			autoFormService.executeSql(deleteFlowTask);
			String deleteFlowTaskInfo = "delete from FLOW_TASK_INFO t where t.FLOW_TASK_ID in ("+idAll+")";
			autoFormService.executeSql(deleteFlowTaskInfo);
			String deleteFlowDetailed = "delete from FLOW_DETAILED t where t.FLOW_TASK_ID in ("+idAll+")";
			autoFormService.executeSql(deleteFlowDetailed);
			
			String strSql = "select TABLE_NAME,MAIN_ID from FLOW_TASK id in ("+idAll+")";
			List lists = autoFormService.findAllBySql(strSql);
			for(int i=0;i<lists.size();i++){
				Object[] objs = (Object[])lists.get(i);
				strSql = "delete from "+objs[0]+" where id='"+objs[1]+"' ";
				autoFormService.executeSql(strSql);
			}
			out.print("{\"result\":\"success\"}");
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}
	
	public void queryYiqigllist() {
		try {
			PrintWriter out = PubMethod.GetPrintWriter(); 
			String flowid = getRequest().getParameter("flowid");
			String yiqiid = getRequest().getParameter("yiqiid");
			
			String renwubh = getRequest().getParameter("renwubh");
			String chanpindh = getRequest().getParameter("chanpindh");
			String shiyanlx = getRequest().getParameter("shiyanlx");
			String state = getRequest().getParameter("state");
			String tianjiar = getRequest().getParameter("tianjiar");
			String starttime = getRequest().getParameter("starttime");
			String endtime = getRequest().getParameter("endtime");

			Map<String, String> filterMap = getPagerMap();
			String userId = this.getUserId();
			String roleId = this.getRole();
			filterMap.put("userId", userId);
			filterMap.put("roleId", roleId);
			filterMap.put("deptId", getDeptid());
			filterMap.put("flowid", flowid);
			filterMap.put("yiqiid", yiqiid);

			if(!"".equals(renwubh)&&renwubh!=null){
				renwubh = java.net.URLDecoder.decode(renwubh,"UTF-8");
				filterMap.put("renwubh", renwubh);
			}
			if(!"".equals(chanpindh)&&chanpindh!=null){
				chanpindh = java.net.URLDecoder.decode(chanpindh,"UTF-8");
				filterMap.put("chanpindh", chanpindh);
			}	
			if(!"".equals(shiyanlx)&&shiyanlx!=null){
				shiyanlx = java.net.URLDecoder.decode(shiyanlx,"UTF-8");
				filterMap.put("shiyanlx", shiyanlx);	
			}
			if(!"".equals(state)&&state!=null){
				state = java.net.URLDecoder.decode(state,"UTF-8");
				filterMap.put("state", state);	
			}
			if(!"".equals(tianjiar)&&tianjiar!=null){
				tianjiar = java.net.URLDecoder.decode(tianjiar,"UTF-8");
				filterMap.put("tianjiar", tianjiar);	
			}
			if(!"".equals(starttime)&&starttime!=null){
				filterMap.put("starttime", starttime);	
			}
			if(!"".equals(endtime)&&endtime!=null){
				filterMap.put("endtime", endtime);
			}
			String[] viewArray = { "flowtaskinfoid","flowtaskid","flow_type_id", "flow_state_id","main_id", "renwubh","chanpindh","shiyanlx","fuzher","shiyandd",
								"shiyankssj","yujijssj","flow_state_name","add_user_name","add_time"};
			// 查询所有的数据
			PageResult result = workflowService.queryYiqigllist(filterMap);
			String returnStr = getColumnJson(result, viewArray);
			out.print(returnStr);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
